﻿using GoogleMapsMVC.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace GoogleMapsMVC.Controllers
{
    public class HomeController : Controller
    {
        private readonly MarkerRepository _markerRepository;
        public HomeController()
        {
            _markerRepository = new MarkerRepository();
        }
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        [HttpGet]
        public ActionResult Sync()
        {
            IdentityDbContext db = new IdentityDbContext();

            return View(db.GoogleMarkers.ToList());
            
            //return View(_markerRepository.GetMarkers());
        }

        [HttpGet]
        public ActionResult Async()
        {
            return View();
        }

        [HttpPost]
        public ActionResult GetMarkersAsync()
        {
            IdentityDbContext db = new IdentityDbContext();

            return Json(db.GoogleMarkers.ToList());
            //return Json(_markerRepository.GetMarkers());
        }

        public ActionResult GoogleMapAsyncTest()
        {
            ViewBag.Message = "ViewBagMessage:GoogleMapAsyncTest.";

            return View();
        }


    }
}